import unittest
from api.emp import Emp
from util import gong_yong


class TestEmp(unittest.TestCase):
    emp_id = None

    def setUp(self):
        self.emp = Emp()

    def test01_add_emp(self):
        add_data = {
            "username": "guanyu",
            "mobile": "13222222225",
            "timeOfEntry": "2020-07-09",
            "formOfEmployment": 1,
            "workNumber": "22225",
            "departmentName": "销售",
            "departmentId": "1266699057968001222",
            "correctionTime": "2020-07-30T16:00:00.000Z"
        }
        response = self.emp.add_emp(add_data=add_data)
        gong_yong(self, response)
        TestEmp.emp_id = response.json().get('data').get('id')
        print(TestEmp.emp_id)

    def test02_modify_emp(self):
        json_data = {"username": "machao"}
        response = self.emp.modify_emp(TestEmp.emp_id, json_data=json_data)
        gong_yong(self, response)

    def test03_get_emp(self):
        response = self.emp.get_emp(emp_id=TestEmp.emp_id)
        gong_yong(self, response)

    def test04_del_emp(self):
        response = self.emp.delete_emp(TestEmp.emp_id)
        gong_yong(self, response)
